using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;

namespace Drive.LiveExcelHost
{
    public class Program
    {
        public static void Main(string[] args)
        {
            RedisVisitorStatus.Reset();
            RedisAgentStatus.Reset();
            RedisWebSocketSession.Reset();
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "spreadsheets")))
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "spreadsheets"));
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureServices((hostContext, services) =>
                {
                    services.AddHostedService<Worker>();
                    services.AddLogging(builder =>
                    {
                        builder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Error);
                        builder.AddNLog(new NLogProviderOptions
                        {
                            CaptureMessageTemplates = true,
                            CaptureMessageProperties = true
                        });
                    });
                });
    }
}
